package com.spring;

import com.alibaba.druid.pool.DruidDataSource;
import com.veo.domain.Product;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;


import java.util.List;

public class Spring {

    @Test
    public void test(){
        ApplicationContext context=new ClassPathXmlApplicationContext("applicationContext.xml");
        DruidDataSource dataResource = (DruidDataSource) context.getBean("dataSource");
        JdbcTemplate jdbcTemplate=new JdbcTemplate(dataResource);
        List<Product> query = jdbcTemplate.query("select * from product", new BeanPropertyRowMapper<Product>(Product.class));
        System.out.println(query);
    }
}
